/* eslint-disable */
import { MENU_CODES, METHOD_TYPE, MODULES } from '@/options';
import useBaseRequest from '@/hooks/useBaseRequest';
import { BaseListUrl, PageType, ResultPage } from '@/types/common/request';
import { request } from '@umijs/max';

type DataType = ORG_TYPE.Info;
type Params = ORG_TYPE.Params;
const ApiUrl = `/${MODULES.SYSTEM}/${MENU_CODES.ORG}`;

export const { getList, addItem, updateItem, delItem, detailItem } = useBaseRequest<
  DataType,
  Params
>(ApiUrl);

/** 获取树形列表 */
export const getTreeList = async (
  params?: PageParams & Partial<Params>,
  options?: { [p: string]: any },
): Promise<PageType<DataType>> => {
  // console.log(params, sort, filter, options);
  const ret = await request<ResultPage<DataType>>(ApiUrl + BaseListUrl.TREE_LIST, {
    method: METHOD_TYPE.GET,
    params,
    ...(options || {}),
  });
  return {
    success: ret.success,
    message: ret.message,
    code: ret.code,
    ...ret.data,
  };
};
